﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PrinteMaster
{
    public partial class 验证会员窗口 : Form
    {
        public 验证会员窗口()
        {
            InitializeComponent();
        }

        private void button刷新_Click(object sender, EventArgs e)
        {
            System.Data.DataSet req;
            DataBase.Error er = DataBase.getInstance().getWaitOkUsers(out req);
            switch (er)
            {
                case DataBase.Error.nothing:
                    MessageBox.Show("没有待验证会员!");
                    return;
                case DataBase.Error.databaseError:
                    MessageBox.Show("数据库发生错误!");
                    return;
            }
            dgv.DataSource = req.Tables[0].DefaultView;
        }

        private void dgv_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            string id = dgv.Rows[e.RowIndex].Cells["编号"].Value.ToString();
            DataBase.Error er = DataBase.getInstance().setWaitOkUser(id);
            var hint = string.Format("确认要对[   {0}  |  {1}  ]进行验证吗?",dgv.Rows[e.RowIndex].Cells["姓名"].Value.ToString(),dgv.Rows[e.RowIndex].Cells["账号"].Value.ToString());
            if (MessageBox.Show(hint, "", MessageBoxButtons.OKCancel) != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            if (er == DataBase.Error.ok)
            {
                MessageBox.Show("验证成功!");
            }
            else
                MessageBox.Show("验证失败!原因=>" + er);

            //dgv.DataSource dgv.CurrentRow.Index;
        }

        private void 验证会员窗口_Load(object sender, EventArgs e)
        {
            button刷新_Click(null, null);
        }
    }
}
